<#
模板目录健康检查（原生 PowerShell）
用途：检查 templates/INDEX.md 以及核心子目录是否存在。
用法：
  pwsh -File scripts/windows/check-templates.ps1
#>
param()

$WindowsDir = Split-Path -Parent $PSCommandPath
$ScriptsDir = Split-Path -Parent $WindowsDir
$RepoDir = Split-Path -Parent $ScriptsDir

$tpl = Join-Path $RepoDir 'templates'
$index = Join-Path $tpl 'INDEX.md'
$subs = @('python','java','mvc','trae') | ForEach-Object { Join-Path $tpl $_ }

$missing = @()
if (!(Test-Path $index)) { $missing += $index }
foreach ($d in $subs) { if (!(Test-Path $d)) { $missing += $d } }

if ($missing.Count -gt 0) {
  Write-Warning "模板目录检查存在缺失：`n - " + ($missing -join "`n - ")
  exit 2
} else { Write-Host "模板目录健康检查通过"; exit 0 }
